package com.opgea.crm.services.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.opgea.crm.domain.entities.security.CrmUser;
import com.opgea.crm.repository.security.CrmUserRepository;

@Service
public class CrmUserServiceImpl implements CrmUserService{

	@Autowired
	CrmUserRepository crmUserRepository;
	
	public CrmUser getCrmUser(String userName){
		return crmUserRepository.findByLoginId(userName);
	}
	
	public CrmUser getCurrentLoggedInUser(){
		//return crmUserRepository.findByLoginId(CrmUser.getCurrentAuthentication().getName());
            return null;
        }

	public void create(CrmUser user) {
		crmUserRepository.create(user);
	}
	
	@Override
	public void update(CrmUser user) {
		crmUserRepository.update(user);
	}

	public CrmUser findByLoginId(String userName) {
		return crmUserRepository.findByLoginId(userName);
	}

	@Override
	public CrmUser findByEmpId(Long empId) {
		return crmUserRepository.findByEmpId(empId);
	}
	
}
